package com.alit.face.koala.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.alibaba.fastjson.JSON;
import com.alit.face.koala.app.data.KoalaEmpLoyeeRequest;
import com.alit.face.koala.app.data.common.KoalaEmpLoyee;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "koala_employee")
public class KoalaEmpLoyeeEntity extends KoalaEmpLoyee {
  @Id
  @GenericGenerator(name = "system-uuid", strategy = "uuid")
  @GeneratedValue(generator = "system-uuid")
  private String id;
  // 人员分组
  private String groupIds;
  // 图片Id
  private String photoIds;
  // 指定百度人脸库中的groupId
  private String baiduGroupId;

  public KoalaEmpLoyeeEntity(String id, KoalaEmpLoyeeRequest employee) {
    setId(id);
    setAvatar(employee.getAvatar());
    setName(employee.getName());
    setJobNumber(employee.getJobNumber());
    setDepartment(employee.getDepartment());
    setTitle(employee.getTitle());
    setEmail(employee.getEmail());
    setPhone(employee.getPhone());
    setEntryDate(employee.getEntryDate());
    setBirthday(employee.getBirthday());
    setDescription(employee.getDescription());
    setRemark(employee.getRemark());
    setGender(employee.getGender());
    setSubjectType(employee.getSubjectType());
    this.groupIds = JSON.toJSONString(employee.getGroupIds());
    this.photoIds = JSON.toJSONString(employee.getPhotoIds());
  }
}
